package com.kenai.jbosh;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;

public class QName
  implements Serializable
{
  private static final String emptyString = "".intern();
  private String localPart;
  private String namespaceURI;
  private String prefix;

  public QName(String paramString)
  {
    this(emptyString, paramString, emptyString);
  }

  public QName(String paramString1, String paramString2)
  {
    this(paramString1, paramString2, emptyString);
  }

  public QName(String paramString1, String paramString2, String paramString3)
  {
    if (paramString1 == null)
      str = emptyString;
    while (true)
    {
      this.namespaceURI = str;
      if (paramString2 != null)
        break;
      throw new IllegalArgumentException("invalid QName local part");
      str = paramString1.intern();
    }
    this.localPart = paramString2.intern();
    if (paramString3 == null)
      throw new IllegalArgumentException("invalid QName prefix");
    this.prefix = paramString3.intern();
  }

  private void readObject(ObjectInputStream paramObjectInputStream)
    throws IOException, ClassNotFoundException
  {
    paramObjectInputStream.defaultReadObject();
    this.namespaceURI = this.namespaceURI.intern();
    this.localPart = this.localPart.intern();
    this.prefix = this.prefix.intern();
  }

  public static QName valueOf(String paramString)
  {
    QName localQName;
    if ((paramString == null) || (paramString.equals("")))
      throw new IllegalArgumentException("invalid QName literal");
    if (paramString.charAt(0) == '{')
    {
      int i = paramString.indexOf(125);
      if (i == -1)
        throw new IllegalArgumentException("invalid QName literal");
      if (i == paramString.length() - 1)
        throw new IllegalArgumentException("invalid QName literal");
      localQName = new QName(paramString.substring(1, i), paramString.substring(i + 1));
    }
    while (true)
    {
      return localQName;
      localQName = new QName(paramString);
    }
  }

  public final boolean equals(Object paramObject)
  {
    int i;
    if (paramObject == this)
      i = 1;
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return i;
          if (paramObject instanceof QName)
            break;
          i = 0;
        }
        if ((this.namespaceURI != ((QName)paramObject).namespaceURI) || (this.localPart != ((QName)paramObject).localPart))
          break;
        i = 1;
      }
      i = 0;
    }
  }

  public String getLocalPart()
  {
    return this.localPart;
  }

  public String getNamespaceURI()
  {
    return this.namespaceURI;
  }

  public String getPrefix()
  {
    return this.prefix;
  }

  public final int hashCode()
  {
    return (this.namespaceURI.hashCode() ^ this.localPart.hashCode());
  }

  public String toString()
  {
    String str;
    if (this.namespaceURI == emptyString)
      str = this.localPart;
    while (true)
    {
      return str;
      str = '{' + this.namespaceURI + '}' + this.localPart;
    }
  }
}